package LinkedList.project;
/*
    LinkedList的使用：特点：双向链表存储，增删速度快
 */

import ArrayList.project.Student;

import java.util.LinkedList;

public class PracticeMain {
    public static void main(String[] args) {
        //1.创建集合：
        LinkedList linkedList = new LinkedList();
        //2.添加元素
        Preson preson1 = new Preson("王",20);
        Preson preson2 = new Preson("李",22);
        Preson preson3 = new Preson("赵",23);
        Preson preson4 = new Preson("王",20);
        linkedList.add(preson1);
        linkedList.add(preson2);
        linkedList.add(preson3);
        linkedList.add(preson4);
        System.out.println(linkedList.size());
        System.out.println(linkedList.toString());

        //3.删除元素
       // linkedList.remove(0);//下标删除
        linkedList.remove(new Student("王",20));

        //4.遍历集合:可使用迭代器Iterator,也可以使用列表迭代器：ListIterator， 也可使用for，也可使用增强for
        for (int i = 1;i<linkedList.size();i++){
            System.out.println(linkedList.get(i));
        }

        //5.判断

    }
}
